[Serve] Optimize pack scheduling from O(replicas × total_replicas) to O(replicas × nodes)#60806
Open
abrarsheikh wants to merge 2 commits intomasterfrom
Open
[Serve] Optimize pack scheduling from O(replicas × total_replicas) to O(replicas × nodes)#60806abrarsheikh wants to merge 2 commits intomasterfrom
abrarsheikh wants to merge 2 commits intomasterfrom
Conversation
… O(replicas × nodes) Signed-off-by: abrar <abrar@anyscale.com>
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a significant optimization to the pack scheduling strategy, reducing its complexity from O(replicas × total_replicas) to O(replicas × nodes). This is achieved by computing available resources and running replica mappings once before scheduling, and then incrementally updating the available resources. The changes are well-implemented and improve performance for large-scale deployments.
I have one suggestion to simplify a conditional check. Also, there's a small typo in the pull request title ('ptimize' should be 'optimize').
Great work on this optimization!
Signed-off-by: abrar <abrar@anyscale.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
_schedule_with_pack_strategywas calling_get_available_resources_per_node()and_get_node_to_running_replicas()per replica being scheduled. Each call iterates over all launching + running replicas across all deployments. With 2048 replicas, this produced O(replicas²) work.available_resources_per_nodeincrementally by subtracting the scheduled replica's resources from the target node after each placement.min(GCS, calculated)result rather than only the calculated side), which is consistent with the existing best-effort semantics of_get_available_resources_per_node.Benchmark with mocked objects
related to #60680